import App from './App'

// #ifndef VUE3
import Vue from 'vue'

import { initWebSocket } from './utils/websocket';
// 初始化WebSocket
initWebSocket();
import uView from '@/uni_modules/uview-ui'
Vue.use(uView)
import './uni.promisify.adaptor'
Vue.config.productionTip = false
// 导入SignIn组件
import SignIn from './components/common/SignIn.vue'
import EmergencyModal from './components/common/EmergencyModal.vue'
// 导入返回按钮组件
import BackButton from './components/common/BackButton.vue'
// 导入订单成功弹窗组件
import OrderSuccessModal from './components/common/OrderSuccessModal.vue'
// 注册全局组件
Vue.component('SignIn', SignIn)
Vue.component('EmergencyModal', EmergencyModal)
Vue.component('BackButton', BackButton)
Vue.component('OrderSuccessModal', OrderSuccessModal)
App.mpType = 'app'
import store from './store'
// 添加事件总线
const eventBus = new Vue()
Vue.prototype.$bus = eventBus

const app = new Vue({
  ...App,
  store  // 确保这行存在，将store注入Vue实例
})

app.$mount()

// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
import { initWebSocket } from './utils/websocket'; // 添加导入
// 初始化WebSocket
initWebSocket(); // 添加初始化调用
// 导入SignIn组件
import SignIn from './components/common/SignIn.vue'
// 导入订单成功弹窗组件
import OrderSuccessModal from './components/common/OrderSuccessModal.vue'

export function createApp() {
  const app = createSSRApp(App)
  // 注册全局组件
  app.component('SignIn', SignIn)
  app.component('OrderSuccessModal', OrderSuccessModal)
  // 添加事件总线
  const eventBus = new Vue()
  app.config.globalProperties.$bus = eventBus
  return { app }
}
// #endif